package wsi.db;

import java.sql.Time;
import java.util.Date;

import org.rygh.core.db.tuple.NamedModel;

public class WebCacheModel extends NamedModel {

	public static final String HASH_CODE = "HASH_CODE";
	public static final String LENGTH = "LENGTH";

	public static final String[] CAPTION = { "T_CACHE_WEB", "T_CACHE_WEB" };

	public static final String[][] COLUMNS = {
	/* 0 */{ ID, ID },
	/* 1 */{ VERSION, VERSION },
	/* 2 */{ NAME, NAME },
	/* 3 */{ HASH_CODE, HASH_CODE },
	/* 4 */{ LENGTH, LENGTH },
	/* 5 */{ DATE_COL, DATE_COL },
	/* 6 */{ TIME_COL, TIME_COL },
	/* 7 */{ CONTENT, CONTENT }, };

	public static final Class<?>[] KLASSES = {
	/* 0 */INT,
	/* 1 */LONG,
	/* 2 */STRING,
	/* 3 */INT,
	/* 4 */INT,
	/* 5 */DATE,
	/* 6 */TIME,
	/* 7 */STRING, };

	public static final int[] INDEX = { 3, };

	public WebCacheModel() {
		setColumns(COLUMNS);

		set(DATE_COL, new Date(System.currentTimeMillis()));
		set(TIME_COL, new Time(System.currentTimeMillis()));
	}

	public String getContent() {
		return get(CONTENT);
	}

	public void setContent(String content) {
		set(CONTENT, content);
		setLength(content.length());
	}

	public void setHashCode(int code) {
		set(HASH_CODE, code);
	}

	public void setLength(int length) {
		set(LENGTH, length);
	}
}
